package com.pri.chat.activity;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.gson.Gson;
import com.luck.picture.lib.PictureSelector;
import com.netease.nim.uikit.net.SharedHelper;
import com.netease.nim.uikit.net.entity.BaseBean;
import com.netease.nim.uikit.net.entity.KeFuEntity;
import com.netease.nim.uikit.net.entity.LookMemberListBean;
import com.netease.nim.uikit.net.entity.PayResultBean;
import com.netease.nim.uikit.net.entity.SuperVipBean;
import com.netease.nim.uikit.net.rxjava.HttpMethods;
import com.netease.nim.uikit.net.subscribers.ProgressSubscriber;
import com.netease.nim.uikit.net.subscribers.SubscriberOnNextListener;
import com.pri.chat.R;
import com.pri.chat.adapter.KeFuMsgAdapter;
import com.pri.chat.adapter.OtherWishAdapter;
import com.pri.chat.base.BaseActivity;
import com.pri.chat.model.RechargePayModel;
import com.pri.chat.pay.PayListenerUtils;
import com.pri.chat.pay.PayResultListener;
import com.pri.chat.pay.PayUtils;
import com.pri.chat.utils.Des3Util;
import com.pri.chat.utils.GlideEngine;
import com.vondear.rxui.view.dialog.RxDialogVIPEditSureCancel;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.OnClick;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * 描述：添加类的描述
 *
 * @author
 * @time 2020/4/29
 */
public class KeFuActivity extends BaseActivity implements PayResultListener {
    @BindView(R.id.rec_main)
    RecyclerView recMain;

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_kefu;
    }

    private KeFuMsgAdapter mAdapter;
    private List<List<KeFuEntity>> mList;

    @Override
    protected void initView() {
        setTitle("平台客服");
        mList = new ArrayList<>();
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        recMain.setLayoutManager(linearLayoutManager);
        mAdapter = new KeFuMsgAdapter(R.layout.item_kefu_msg, mList);
        recMain.setAdapter(mAdapter);
        mAdapter.setOnAdapterClickListener(new KeFuMsgAdapter.OnAdapterClickListener() {
            @Override
            public void onAdapterClick(KeFuEntity kefuObj) {
                List<KeFuEntity> tempList = new ArrayList<>();
                tempList.add(kefuObj);
                mAdapter.addData(tempList);
            }
        });
    }

    private List<KeFuEntity> tempList;
    @Override
    protected void initData() {
        SubscriberOnNextListener<BaseBean<List<KeFuEntity>>> onNextListener = baseBean -> {
            tempList = baseBean.getData();
            mList.add(tempList);
            mAdapter.setNewData(mList);
        };
        Map<String, Object> params = new HashMap<>();
        params.put("code", "systemKeFu");
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), Des3Util.getJiaMi(params));
        HttpMethods.getInstance().getDictionaryItemList(new ProgressSubscriber<>(onNextListener, this, true), requestBody);
    }

    @Override
    public void onPaySuccess() {
        finish();
    }

    @Override
    public void onPayError() {

    }

    @Override
    public void onPayCancel() {

    }
}
